<?php


namespace app\adminbackstage\model;


use think\facade\Db;
use think\Model;

class Recharge extends Model
{
    protected $type = [
        'action_data' => 'json',

    ];
    //充值列表
    public static function rechargeList($where,$pageIndex,$pageSize){
        return Db::name('recharge')
            ->alias('r')
            ->field('r.*,u.phone')
            ->join('user u','u.uid = r.uid')
            ->json(['r.action_data'])
            ->where($where)
            ->order('r.id desc')
            ->page($pageIndex,$pageSize)
            ->select();
    }

    //充值列表数据总条数
    public static function rechargeCount($where){
        return Db::name('recharge')
            ->alias('r')
            ->join('user u','u.uid = r.uid')
            ->where($where)
            ->count();
    }

    //充值详情
    public static function rechargeView($where){
        return self::where($where)->find();
    }


    //充值记录修改
    public static function rechargeEdit($where,$data){
        return self::update($data,$where);
    }
}